# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html
import pickle

class DangdangspiderPipeline(object):
    def process_item(self, item, spider):
        print("书名："+item['title'][0])
        print("评论数："+item['num'][0])
        print("价格"+item['price'])

        booklist = []
        booklist.extend([item['title'],item['num'],item['price']])
        pickle_file = open('index.txt','wb')
        pickle.dump(booklist,pickle_file);
        pickle_file.close()

        pickle_file = open('index.txt','rb')
        t = pickle.load(pickle_file)

        return item
